<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<title>许愿树</title>
<link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css">
<link rel="stylesheet/less" href="__PUBLIC__/css/style.less" />
<link rel="stylesheet/less" href="__PUBLIC__/css/font-awesome.min.css" />
<script src="__PUBLIC__/js/less-1.5.0.min.js"></script>
<script src="__PUBLIC__/js/jquery-1.11.0.min.js"></script>
<script src="__PUBLIC__/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/js/bootbox.js"></script>
<script>
	$(document).ready(function(){
	    $('.img_friends').css('height',$('.img_friends').css('width'));
	    
	    window.setTimeout(function(){
	    	$("#once").css('display','none');
	    	$("#light").css('display','none');
	    },2000);
	})


	/*setInterval(function() {
		window.location.reload();
	},2000);*/
	function irrigate(tree_id){
		$.ajax({
	        url: '__URL__/irrigate',
	        data: 'tree_id='+tree_id,
            type: 'POST',
            success: function(res) {
               if(res!=0) {
            	    var num=1;
	           		var inter=setInterval(function() {
	           			if(num<4){
	           				$("#bottlespan").html('<img src="__PUBLIC__/img/irrigate'+num+'.png" alt="" class="bottle2">');
	           				num=num+1;
	           			}
	           			else{
	           				clearInterval(inter);
	           				$("#bottlespan").html('<img src="__PUBLIC__/img/bottle.png" alt="" class="bottle">');
	           				$("#digitspan").html( parseInt($("#digitspan").html())+1 );
	           				
	           				var addDiv='<div class="friends">'+
					        				'<div class="friends-name left">'+res+'</div>'+
					        				'<div class="friends-time left">刚刚</div>'+
					        				'<div class="c"></div>'+
					        			'</div>'
		        			$('#friendsdiv').append(addDiv);
	           				
	           			}
	           		},500);
               	   
               } else if(res==0) {
                   bootbox.alert('您已经浇过水啦~一个人只能浇一次水哦~');
               }
            }      
   		});
		
		
	}
	
	
	
	//微信分享
	//朋友圈
	wx.onMenuShareTimeline({
    title: '快来帮我浇{$re.id}号树~浇树获得购房款~', // 分享标题
    link: '', // 分享链接
    imgUrl: '', // 分享图标
    success: function () { 
        // 用户确认分享后执行的回调函数
    },
    cancel: function () { 
        // 用户取消分享后执行的回调函数
    }
});
	
	//分享给朋友
	wx.onMenuShareAppMessage({
    title: '快来帮我浇{$re.id}号树~浇树获得购房款~', // 分享标题
    desc: '', // 分享描述
    link: '', // 分享链接
    imgUrl: '', // 分享图标
    type: '', // 分享类型,music、video或link，不填默认为link
    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
    success: function () { 
        // 用户确认分享后执行的回调函数
    },
    cancel: function () { 
        // 用户取消分享后执行的回调函数
    }
});

</script>
<!--[if lt IE 9]>
<script src="__PUBLIC__/js/html5shiv.js"></script>
<![endif]-->
</head>
<body class="irrigate-bg">
	<div class="gray"></div>
	<header>
		<div class="header-image">	
			<!-- <div class="image-border">
				<img src="__PUBLIC__/img/image.jpg" class="image" alt="">
			</div>	 -->
			<img src="__PUBLIC__/img/image2.png" class="image-bg" alt="">
		</div>
	</header>

	<section>
		<div class="">
			<div class="left"><img src="__PUBLIC__/img/irrigate.png" onclick="irrigate({$re.id});" ></div>
			<div class="right">
				<if condition="$iftree==1">
				<img src="__PUBLIC__/img/plant.png" onclick="bootbox.alert('您已经有自己的小树苗了~');">
				<else />
				<img src="__PUBLIC__/img/plant.png" onclick="window.location.href='__MODULE__/Index/tree';">
				</if>
			</div>
		</div>
		<div class="c"></div>
		<div class="irrigate">
			<if condition="$re['water_num'] lt 10">
			<div class="grade">目前等级:  1级</div>
			<div class="number">{$re.id}号树</div>
			<span id="bottlespan"><img src="__PUBLIC__/img/bottle.png" alt="" class="bottle"></span>
			<img src="__PUBLIC__/img/seed1.png" alt="" class="seed">
			<elseif condition="$re['water_num'] lt 100 "/>
			<div class="grade">目前等级:  2级</div>
			<div class="number">{$re.id}号树</div>
			<span id="bottlespan"><img src="__PUBLIC__/img/bottle.png" alt="" class="bottle"></span>
			<img src="__PUBLIC__/img/seed10.png" alt="" class="seed" >
			<elseif condition="$re['water_num'] lt 1000"/>
			<div class="grade">目前等级:  3级</div>
			<div class="number">{$re.id}号树</div>
			<span id="bottlespan"><img src="__PUBLIC__/img/bottle.png" alt="" class="bottle"></span>
			<img src="__PUBLIC__/img/seed100.png" alt="" class="seed">
			<elseif condition="$re['water_num'] lt 10000"/>
			<div class="grade">目前等级:  4级</div>
			<div class="number">{$re.id}号树</div>
			<span id="bottlespan"><img src="__PUBLIC__/img/bottle.png" alt="" class="bottle"></span>
			<img src="__PUBLIC__/img/seed1000.png" alt="" class="seed">
			<else />
			<div class="grade">目前等级:  5级</div>
			<div class="number">{$re.id}号树</div>
			<span id="bottlespan"><img src="__PUBLIC__/img/bottle.png" alt="" class="bottle"></span>
			<img src="__PUBLIC__/img/seed10000.png" alt="" class="seed">
			</if>
		</div>
		<if condition="$new">
		<div class="once" id="once" style="display:block;">
			<img src="__PUBLIC__/img/once.png" class="once_img">
		</div>
		<div class="light" id="light" style="display:block;">
			<img src="__PUBLIC__/img/light.png" class="light_img">
		</div>
		<else />
		<div class="once">
			<img src="__PUBLIC__/img/once.png" class="once_img">
		</div>
		<div class="light">
			<img src="__PUBLIC__/img/light.png" class="light_img">
		</div>
		</if>
	</section>

	<footer>
		<div>
			<div class="button-bg">已获帮助 <span class="digit" id="digitspan">{$re.water_num}</span>次</div>
			<div class="pink-bg">帮我浇水的好友</div>

			<if condition="$friends">
			<div class="friendsdiv" id="friendsdiv">
<!-- 好友循环开始处 -->
			<foreach name="friends" item="v" key="k">
			<div class="friends">
				<!-- <div class="friends-img left">
					<img src="__PUBLIC__/img/image.jpg" class="img-circle img_friends" style="width:100%;">
				</div> -->
				<div class="friends-name left">{$v.mobile}</div>
				<div class="friends-time left">{$v.time|date='Y-m-d',###}</div>
				<div class="c"></div>
			</div>
			</foreach>
<!-- 好友循环结束处 -->
			</div>
			<else/>
			<div class="pink-center-title">赶快去找好友帮忙吧~</div>
			</if>

			<div class="rule-title">活动规则</div>
			<div class="pink-center">
				
				1、客户扫描二维码即可登陆砍价树页面；<br/>
				2、发布砍价愿望，生成砍价树树种；<br/>
				3、所有关注微信平台的客户都可帮忙砍价，每人可以砍价一次，每砍价一次，优惠金额上升1元；<br/>
				4、此优惠可用于活动楼盘的所有户型，与楼盘其他优惠可叠加，不冲突；<br/>
				5、砍价树页面存在于楼盘官方页面和微年代-嘉兴 楼市官方平台，两棵砍价树数值相加，即客户可获得的最终优惠总金额。
			</div>
		</div>
	</footer>
	
</body>
</html>